package com.task.manager.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

import com.task.manager.domain.Actuator;

public interface ActuatorMapper {
	@Delete({ "delete from t_actuator", "where ID = #{id,jdbcType=INTEGER}" })
	int deleteByPrimaryKey(Integer id);

	@Insert({ "insert into t_actuator (ID, ACTUATOR_NAME, ", "ACTUATOR_CLASS, ACTUATOR_TYPE, ", "ACTUATOR_CODE, ACTUATOR_PROTOCOL, ", "ACTUATOR_METHOD)",
			"values (#{id,jdbcType=INTEGER}, #{actuatorName,jdbcType=VARCHAR}, ", "#{actuatorClass,jdbcType=VARCHAR}, #{actuatorType,jdbcType=VARCHAR}, ",
			"#{actuatorCode,jdbcType=VARCHAR}, #{actuatorProtocol,jdbcType=VARCHAR}, ", "#{actuatorMethod,jdbcType=VARCHAR})" })
	int insert(Actuator record);

	@InsertProvider(type = ActuatorSqlProvider.class, method = "insertSelective")
	int insertSelective(Actuator record);

	@Select({ "select", "ID, ACTUATOR_NAME, ACTUATOR_CLASS, ACTUATOR_TYPE, ACTUATOR_CODE, ACTUATOR_PROTOCOL, ", "ACTUATOR_METHOD", "from t_actuator", "where ID = #{id,jdbcType=INTEGER}" })
	@Results({ @Result(column = "ID", property = "id", jdbcType = JdbcType.INTEGER, id = true), @Result(column = "ACTUATOR_NAME", property = "actuatorName", jdbcType = JdbcType.VARCHAR),
			@Result(column = "ACTUATOR_CLASS", property = "actuatorClass", jdbcType = JdbcType.VARCHAR), @Result(column = "ACTUATOR_TYPE", property = "actuatorType", jdbcType = JdbcType.VARCHAR),
			@Result(column = "ACTUATOR_CODE", property = "actuatorCode", jdbcType = JdbcType.VARCHAR),
			@Result(column = "ACTUATOR_PROTOCOL", property = "actuatorProtocol", jdbcType = JdbcType.VARCHAR),
			@Result(column = "ACTUATOR_METHOD", property = "actuatorMethod", jdbcType = JdbcType.VARCHAR) })
	Actuator selectByPrimaryKey(Integer id);

	@UpdateProvider(type = ActuatorSqlProvider.class, method = "updateByPrimaryKeySelective")
	int updateByPrimaryKeySelective(Actuator record);

	@Update({ "update t_actuator", "set ACTUATOR_NAME = #{actuatorName,jdbcType=VARCHAR},", "ACTUATOR_CLASS = #{actuatorClass,jdbcType=VARCHAR},", "ACTUATOR_TYPE = #{actuatorType,jdbcType=VARCHAR},",
			"ACTUATOR_CODE = #{actuatorCode,jdbcType=VARCHAR},", "ACTUATOR_PROTOCOL = #{actuatorProtocol,jdbcType=VARCHAR},", "ACTUATOR_METHOD = #{actuatorMethod,jdbcType=VARCHAR}",
			"where ID = #{id,jdbcType=INTEGER}" })
	int updateByPrimaryKey(Actuator record);

	@Select({ "select", "ID, ACTUATOR_NAME, ACTUATOR_CLASS, ACTUATOR_TYPE, ACTUATOR_CODE, ACTUATOR_PROTOCOL, ", "ACTUATOR_METHOD", "from t_actuator",
			"where ACTUATOR_CODE = #{code,jdbcType=VARCHAR}" })
	Actuator selectActuatorByCode(String code);

	@Select({ " select ", " * ", " from t_actuator " })
	List<Actuator> queryAll();
	
	@SelectProvider(type = ActuatorSqlProvider.class, method = "queryActuatorByParam")
	List<Actuator> queryActuatorByParam(Actuator record);
}